package com.edu.buservice.util.model.error;

import com.edu.buservice.util.model.enums.ErrorCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * @program: KQAIA
 * @description:
 * @author: 无恙
 * @create: 2025-02-09 19:25
 **/


@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
public class BizException extends RuntimeException {

	private String code;

	private String message;

	private ErrorCodeEnum errorEnum;

	public BizException(ErrorCodeEnum errorEnum) {
		this.code = errorEnum.getCode();
		this.message = errorEnum.getMessage();
		this.errorEnum = errorEnum;
	}

	public BizException(ErrorCodeEnum errorEnum, String message) {
		this.code = errorEnum.getCode();
		this.message = message;
		this.errorEnum = errorEnum;
	}

	public BizException(String code, String message) {
		this.code = code;
		this.message = message;
		this.errorEnum = null;
	}


}
